home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Text / send-script-101 / Send Script Documentation next >
Encoding:
Text File  |  1993-02-04  |  6.6 KB  |  163 lines  |  [TEXT/R*ch]

  1. Send Script Version 1.0.1 -- Extension for BBEdit 2.2 or Later
  2. ==============================================================
  3.  
  4. • Legal Stuff
  5.  
  6. Copyright © 1993 Ed Watkeys (edw@distant.uucp or edw%distant@bts.com)
  7. This software may be copied freely, provided that the documentation (this
  8. file) is retained, and that you do not profit monetarily from its further
  9. distribution. It may, however, be distributed by bulletin board systems
  10. and on-line information services. If you would like to distribute Send
  11. Script in any sort of software collection, you must contact me and get my
  12. permission before doing so.
  13.  
  14. You are under no legal or moral obligation to pay anything for this
  15. software, however, I'm not going to stop you if you want to. Comments and
  16. suggestions, however, are encouraged.
  17.  
  18. I've stopped distributing the source code along with the extension, as I
  19. imagine most people don't really care about it. If you would like the
  20. source code, simply send a letter to "sendscript-source@distant.uucp" or
  21. "sendscript-source%distant@bts.com" -- the source will automatically be
  22. sent to you. By the way, I wrote Send Script in THINK C 5.0.
  23.  
  24. Edwin H. Watkeys III
  25. 1616 Upper State Road
  26. North Wales, PA 19454
  27.  
  28. • Instructions
  29.  
  30. Send Script simply allows you to use BBEdit to write and send scripts to
  31. other programs via the do-script Apple event. Examples of programs which
  32. accept scripts are FileMaker Pro, UserLand Frontier, StuffIt Deluxe, the
  33. Alpha text editor, Tim Endre's TCL implementation for the Macintosh,
  34. tickle, and of course, HyperCard 2.1. Note: you will have problems sending
  35. scripts to Alpha and StuffIt Deluxe unless you have versions 5.3 and 3.0.5,
  36. respectively.
  37.  
  38. Before you send a script, you'll need a script to send. All of the
  39. examples I give will be for UserLand Frontier -- that's what I used for
  40. testing.
  41.  
  42. If you select "Send Script…" without a selection, Send Script will assume
  43. you want the entire current document sent. Otherwise, Send Script will
  44. send only the text you have selected.
  45.  
  46. Tip: Make sure you press the return key after the end of yor script, and
  47. select the return character, too. Results are inserted immediately after
  48. the script, and will be begin on the same line as your script if you don't
  49. make a carriage return the last character in your script.
  50.  
  51. Here's a sample UserLand Frontier script:
  52.  
  53. message = "This is a test" + char(13);
  54. message = message + "of Send Script." + char(13);
  55. return(message);
  56.  
  57. Select it, and choose "Send Script…" from the Extensions menu. You will be
  58. confronted with a dialog box. Here's a list of the items, along with their
  59. purposes:
  60.  
  61. 1. "Select Target…" -- click here to bring up a browser which allows you
  62.    select which application will receive your script. Your selection is
  63.    saved in Send Script's preferences, so that you don't need to change
  64.    do this except when you want to change your target.
  65.  
  66. 2. "Put Results in New Document" -- check this if you want the results of
  67.    your script to appear in a new document. Otherwise, they will appear
  68.    immediately after the script you selected. This item's default state is
  69.    determined by wether or not you selected anything in the current
  70.    document -- if you did, Send Script will by default insert the results
  71.    in the original document. If you didn't, it'll will by default put the
  72.    results in a new document. Because of this, your selection is not saved
  73.    in Send Script's preferences.
  74.  
  75. 3. "Timeout" -- these radio buttons allow you to tell Send Script how long
  76.    to wait for a reply to your script. If the timeout runs out, it'll stop
  77.    waiting for a reply and will exit. The default timeout is about a
  78.    minute.  A reason to change this is if your script requires user
  79.    interaction, and you don't know how long it will take for the user to
  80.    make his/her decision. I'm not sure what you'd want no timeout for, but
  81.    put it there for the sake of completeness. This option is saved in Send
  82.    Script's preferences.
  83.  
  84. 4. "OK" and "Cancel" -- click on "Cancel" and we'll forget any of this
  85.    ever happened. Click on "OK", and Send Script will go ahead and send
  86.    your script. The watch cursor comes up, and you will wait, unless you
  87.    press command-period to cancel the script, in which case you return to
  88.    BBEdit. The "OK" button will be unavailable if there is no currently
  89.    selected target. Just because the "OK" button is available, it doesn't
  90.    mean you have a valid target, so unless you know what it is, it might
  91.    be a good idea to check. In practice, the only times that "OK" will be
  92.    unavailable is the first time you run Send Script with a new copy of
  93.    BBEdit, or if you throw away the BBEdit Preferences file.
  94.  
  95. The above descriptions should give you a pretty good idea of how to use
  96. Send Script.
  97.  
  98. • Notes for Frontier Users
  99.  
  100. If you execute the following script from BBEdit:
  101.  
  102. msg("Have a nice day.");
  103.  
  104. You will find that it returns "true". It'll put a message in Frontier's
  105. message window, but that might not be what you were thinking of. If you
  106. want to turn BBEdit into your "standard out", you're going to need to do
  107. something else. I suggest you create an item in the object database called
  108. "stdout" and write your scripts like this:
  109.  
  110. on WriteLn(message)
  111. {
  112.     people.edw.stdout = people.edw.stdout + string(message) + char(13);
  113. };
  114.  
  115. on Write(message)
  116. {
  117.     people.edw.stdout = people.edw.stdout + string(message);
  118. };
  119.  
  120. on InitStdout()
  121. {
  122.     people.edw.stdout = "";
  123. };
  124.  
  125. InitStdout();
  126. WriteLn("Hello, my name is Ed.");
  127. WriteLn("What is your name?");
  128. return(people.edw.stdout);
  129.  
  130. The above example will return the following:
  131.  
  132. Hello, my name is Ed.
  133. What is your name?
  134.  
  135. So, you see, there isn't a lot to it. Don't forget to put your own
  136. "initials" where "edw" is. This isn't the only way to do it, it's just one
  137. that I usually use because it makes using Frontier scripts more natural
  138. from BBEdit. You can put the above routines in your own "home" table if
  139. you wish -- I just did it this way to show you how I do it.
  140.  
  141. • Misc. Stuff
  142.  
  143. I hope you enjoy Send Script. If you have found any novel uses for it or
  144. you hate something about it that you'd like me to change, feel free to
  145. tell me.
  146.  
  147. I'm not really sure about what you can actually use Send Script for. I
  148. wrote it because I thought it was a cool idea, not because I had a use for
  149. it. When you think about it, using BBEdit to send scripts to Frontier
  150. makes little if any sense!
  151.  
  152. Let me know if there are any other BBEdit Extensions you'd like to see --
  153. I'll consider writing any which aren't insanely boring. Don't know what
  154. I'd call boring, so I you'll have to ask me about anything you have in
  155. mind.
  156.  
  157. • Changes Since Version 1.0
  158.  
  159. 1.0.1:    Fixed all known bugs in 1.0.
  160.         Changed documentation a bit.
  161.         Send Script won't get upset if there is neither a direct object
  162.             nor an error string in the reply Apple event.
  163.